a5TransForm_CreateFromInstance Function
Syntax
P result = a5TransForm_CreateFromInstance(C apiKey, C formId,C formDataJSON [,C assignTo])
Arguments
- apikeyCharacter
Your TransFrom API key. You can get an API key from the Developer Options section located on the Home tab in TransForm Central.
- formidCharacter
This is the ID of the TransForm form definition for which you want to get data.
- formDataJSONCharacter
This is the data for the new form instance. It is in the form of a JSON string.
- assignToCharacter
Default = "". The User to assign the form instance to. E.g. "[email protected]"
Returns
- resultPointer
Returns an object that contains the result of the function. The object will have these properties:
- errorLogical
true/false
- errorText
If error is true, a description of the error
- resultNumeric
A property with the formInstanceId of the new form. (The formInstanceId is the primary key of the new record that was created.)
Description
Create a New TransForm Form Instance.
Discussion
This function is a wrapper on the TransForm CreateNewFormInstance API method. It allows you to create a new form instance and assign the instance to a particular user.
Creating a new form instance programmatically is typically done is "dispatch applications". When the user to whom the new form instance was assigned opens TransForm on their device and performs a refresh action, the new form instances assigned to that user will appear in the list of existing forms. This is called a "dispatch application" because a new task has been "dispatched" to a user.
Example
Assume you have a form called "Pictures" and you want to create a new form instance with the data shown below, and you want to assign this new form instance to a user called [email protected].
dim formId as c = "Pictures" dim apikey as c = "xxxxxxxxxxxxxxxxxxxxxxxxxx" dim assignTo as c = "[email protected]" dim formDataJSON as c formDataJSON = <<%txt% { "field1": "value1", "field2": "value2", "photos": [ {"photo": "https://mys3bucket.s3.amazonaws.com/image1.jpg"}, {"photo": "https://mys3bucket.s3.amazonaws.com/image4.jpg"} ] } %txt% dim pResult as p pResult = a5TransForm_CreateFromInstance(apikey,formid,formdataJson,assignTo)
The a5TransForm_CreateFromInstance() function is a convenient ways to use the TransForm API from Xbasic. It does not add any additional functionality to the API. You can use the API in your Xbasic code to achieve the same results.
See Also